import axios from 'axios';
import React, { useEffect } from 'react'
import cheerio from 'cheerio'
export default function TouTiao() {
  useEffect(() => {
    let url = '/toutiao/hot-event/hot-board/?origin=toutiao_pc&_signature=_02B4Z6wo00d01pYmRMAAAIDCFiS-gndWBP6WAkBAAMEVrFJO1cxobqzqoaSI8JfE.MXVtXmwMzTHYuBOoyFjIA0-5RiMlmfGpDZLrF6jwFI7NNmm5g74Yp12Si03ixcPHJqQTX.3OeG9rQL.4b';
    axios.get(url)
    .then(res => {
      console.log(res);
    });
  }, []);


  useEffect(() => {
    let url = '/douban';
    axios.get(url).then(({data}) => {
      // console.log(data);
      // const $ = cheerio.load(data);
      // // console.log($('.title a').html());
      // $('.title a').each(function() {
      //   console.log(this.children[0].data);
      // })

      //编写正则  <li class="title"><a>afwiaefw</a>
      let reg = /<li class="title">.*?<a.*?>(.*?)<\/a>/isg

      //匹配
      // let result = reg.exec(data)
      // console.log(result);
      let res;
      while(res = reg.exec(data)){
        console.log(res[1]);
      }
    })
  }, [])

  return (
    <div>TouTiao</div>
  )
}
